package qc.module.demo.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import qc.module.demo.dto.student.StudentAddDto;
import qc.module.demo.dto.student.StudentDto;
import qc.module.demo.entity.Student;

import java.util.List;

/**
 * StudentMapper
 */
@Mapper
public interface StudentMapper {
    StudentMapper MAPPER = Mappers.getMapper(StudentMapper.class);

    @Mapping(source = "inschoolday", target = "inSchoolDay")
    @Mapping(source = "homeaddress", target = "homeAddress")
    @Mapping(source = "classcode", target = "classCode")
    StudentDto toDto(Student entity);
    
    @Mapping(target = "no", ignore = true)
    Student toEntity(StudentDto dto);
    
    @Mapping(target = "no", ignore = true)
    @Mapping(target = "birthday", ignore = true)
    @Mapping(target = "inschoolday", ignore = true)
    @Mapping(target = "classcode", ignore = true)
    @Mapping(target = "phone", ignore = true)
    @Mapping(target = "homeaddress", ignore = true)
    Student toEntity(StudentAddDto dto);
    
    List<StudentDto> toDtoList(List<Student> entities);
}
